/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package game;

import define.PhongChoi;
import define.TaiNguyen;
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.*;


/**
 *
 * @author CONGMAN
 */
public class MenuGame extends GameObject{

    BufferedImage bg;
    Font font;

    PhongChoi pc;
    public MenuGame()
    {
        pc = new PhongChoi();
        pc.KhoiTaoPhongChoi(4);
        pc.ChiaBai();
        try{
            bg = ImageIO.read(new File(TaiNguyen.menu_background));
        }
        catch(IOException ioe)
        {
            System.out.println("Load anh bi loi...");
        }
        try{
            File ttf = new File("JOKERMAN.TTF");
            FileInputStream fis = new FileInputStream(ttf);
            font = Font.createFont(Font.TRUETYPE_FONT, fis);
            font = font.deriveFont(Font.PLAIN,80);
        }
        catch (FontFormatException ex) {
            font = new Font("Times New Roman",Font.PLAIN,50);
            Logger.getLogger(MenuGame.class.getName()).log(Level.SEVERE, null, ex);
        }        catch(IOException ioe){
            font = new Font("Times New Roman",Font.PLAIN,50);
        }
    }

    @Override
    public void draw(Graphics g)
    {
        Graphics2D g2D = (Graphics2D)g;
        g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2D.setFont(font);
        Color xanhlucneon = new Color(0.807F,1F,0F);
        //Color butterscotch = new Color(255,204,102);
        Color myhearts = new Color(255,104,102);
        g2D.setColor(xanhlucneon);
        //g2D.setBackground(xanhlucneon);
        //FontMetrics fm = JFrame.getFrames()[0].getFontMetrics(font);
        //int x = fm.stringWidth("My Hearts");
        //int y = 150;
        int width = JFrame.getFrames()[0].getWidth();
        int height = JFrame.getFrames()[0].getHeight();
        g2D.fillRect(0, 0, width, height);
        g2D.drawImage(bg, 0, 0,JFrame.getFrames()[0]);
        
        int vex = 0;
        int vey = 0;
        for(int i = 0; i < 4; i++)
        {
            for(int j = 0; j < 13; j ++)
            {
                vex = j*55 + 20;
                vey = i*130 + 80;
                try {
                    g2D.drawImage(ImageIO.read(new File(TaiNguyen.bobai + String.valueOf(pc.getDsNguoiChoi()[i].LietKeBai()[j]) + ".png")), vex, vey, JFrame.getFrames()[0]);
                } catch (IOException ex) {
                    Logger.getLogger(MenuGame.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            System.out.print("\r\n");
        }
        g2D.setColor(myhearts);
        g2D.drawString("My Hearts", 200, 100);
    }

    @Override
    public void update()
    {}
}
